<template>
    <div>
        <a-drawer
                title="Basic Drawer"
                placement="right"
                :closable="false"
                @close="onClose"
                :visible="visible"
        >
            <template v-slot:handle>
                <div class="handle " @click="visible=!visible">
                    <a-icon :type="visible?'close':'setting'"/>
                </div>
            </template>
            <h2>整体风格定制</h2>
            <a-radio-group :value="navTheme"
                           @change="e=>handleSettingChange('navTheme',e.target.value)">
                <a-radio value="dark">黑色</a-radio>
                <a-radio value="light">白色</a-radio>
            </a-radio-group>
            <h2>导航模式</h2>
            <a-radio-group :value="navLayout"
                           @change="e=>handleSettingChange('navLayout',e.target.value)">
                <a-radio value="left">左边</a-radio>
                <a-radio value="top">右边</a-radio>
            </a-radio-group>
        </a-drawer>
    </div>
</template>

<script>
  import ARadioGroup from "ant-design-vue/es/radio/Group";

  export default {
    name: "index",
    components: { ARadioGroup },
    computed: {
      navTheme() {
        return this.$route.query.navTheme || "dark";
      },
      navLayout() {
        return this.$route.query.navLayout || "left";
      }
    },
    data() {
      return {
        visible: false
      };
    },
    methods: {
      handleSettingChange(type, value) {
        this.$router.push({ query: { ...this.$route.query, [type]: value } });
      },
      onClose() {
        this.visible = false;
      }
    }
  };
</script>

<style scoped>
    .handle {
        position: absolute;
        right: 255px;
        top: 240px;
        font-size: 20px;
        width: 48px;
        height: 48px;
        background-color: #1890ff;
        color: #fff;
        text-align: center;
        line-height: 48px;
        border-radius: 3px 0 0 3px;
    }
</style>